package org.shindou09.easytagforpage.struts2.components;

import java.io.Writer;

import org.apache.struts2.components.Component;
import org.shindou09.easytagforpage.view.PageView;
import org.shindou09.easytagforpage.view.PageViewFactory;

import com.opensymphony.xwork2.util.ValueStack;

public class Page extends Component {

	private String url;

	private String name;

	private String theme;
	
	private String template;

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getTheme() {
		return theme;
	}

	public void setTheme(String theme) {
		this.theme = theme;
	}
	
	public void setTemplate(String template) {
		this.template = template;
	}

	public Page(ValueStack stack) {
		super(stack);
		// TODO Auto-generated constructor stub
	}

	@Override
	public boolean start(Writer writer) {
		// TODO Auto-generated method stub
		boolean start = super.start(writer);
		org.shindou09.easytagforpage.Page page=(org.shindou09.easytagforpage.Page)this.findValue(name);
		String newUrl=this.findString(url);
		PageView pageView=PageViewFactory.getPageView(template);
		pageView.setTheme(this.theme);
		pageView.getView(page, newUrl, writer);
		return start;
	}

}
